<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="./js/vue.js"></script>
  </head>
  <body>
    <div id="app">
      <table width="300" border="1" style="border-collapse: collapse">
        <tr>
          <th>是否选中</th>
          <th>商品名称</th>
          <th>备注</th>
        </tr>
        <tr v-for="item in shopCar" :key="item.id">
          <th>
            <input type="checkbox" v-model="item.isChecked" />
          </th>
          <th>{{item.name}}</th>
          <th></th>
        </tr>
      </table>
      <div><input type="checkbox" v-model="allCheck" /> 全选</div>
    </div>
  </body>
</html>
<script>
  Vue.config.productionTip = false;
  const vm = new Vue({
    el: '#app',
    data() {
      return {
        shopCar: [
          { id: 1, name: '素力高猫粮', isChecked: false },
          { id: 2, name: '抗原试纸', isChecked: false },
          { id: 3, name: '布洛芬缓释胶囊', isChecked: false },
        ],
      };
    },
    computed: {
      /*
        
        */

      allCheck: {
        get() {
          return this.shopCar.every((item) => item.isChecked);
        },
        set(value) {
          this.shopCar.forEach((item) => {
            item.isChecked = value;
          });
        },
      },
    },
  });
</script>
